
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>login</title>
    <meta http-equiv="Content-Type" Content="text/html;charset=UTF-8" />
</head>
<!--  thymeleaf 引入文件方式  @   / 代表初始static目录-->
<script type="text/javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" type="text/css"
      href="/bootstrap/css/bootstrap.css" />
<script type="text/javascript"
        src="/validation/jquery.validate.js"></script>
<script type="text/javascript"
        src="/validation/jquery.validate.min.js"></script>
<script type="text/javascript"
        src="/validation/messages_zh.min.js"></script>
<script type="text/javascript" src="/layer/layer.js"></script>
<script type="text/javascript" src="/js/md5.js"></script>
<script type="text/javascript" src="/js/common.js"></script>

<body style="background-color:rgb(236,221,202) ">
<form name="loginform" id="loginform" method="post"
      style="width: 50%; margin: 15% 0 0 28% ">
    <h2 style="text-align: center; margin-bottom: 20px">用户登录</h2>
    <div class="form-group">
        <div class="row">
            <label class="form-label col-md-4">请输入手机号码</label>
            <div class="col-md-5">
                <input id="id" name="id" class="form-control" type="text"
                       placeholder="手机号码" required="true" minlength="11" maxlength="11"></input>
            </div>
            <div class="col-md-1"></div>
        </div>
    </div>
    <div class="form-group">
        <div class="row">
            <label class="form-label col-md-4">请输入密码</label>
            <div class="col-md-5">
                <input id="password" name="password" class="form-control"
                       type="password" placeholder="密码" required="true" minlength="6"
                       maxlength="6"></input>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-5">
            <button class="btn btn-primary btn-block" type="reset"
                    onclick="reset()">重置</button>
        </div>
        <div class="col-md-5">
            <button class="btn btn-primary btn-block" type="submit"
                    onclick="login()">登录</button>
        </div>
    </div>
</form>
</body>
<script>
    function login(){
        $("#loginform").validate({
            submitHandler:function(form){
                dologin();
            }
        })
    }

    function dologin(){
        g_showLoading();
        var pass = document.getElementById("password").value;
        var id = document.getElementById("id").value;
        var salt = g_password_salt;
        //var str =  salt.charAt(0) + salt.charAt(1) + pass + salt.charAt(3) + salt.charAt(5);
        //var password = md5(str);
        //alert(password);
        $.ajax({
            url:"/main/doLogin",
            type:"POST",
            data:{
                id:id,
                password:pass,
                salt:salt
            },
            success:function(data){
                layer.closeAll();
                if(data.code == 0){
                    layer.msg("登陆成功");
                    window.location.href="/menu/toMenu"
                }else{
                    layer.msg(data.msg);
                }
            },
            error:function(){
                layer.closeAll();
            }
        })
    }
</script>
</html>